// CSerial.h: interface for the CSerial class. // ////////////////////////////////////////////////////////////////////// #if !defined(AFX_CSERIAL_H__631473E2_F58F_42EF_BB8E_3CBEC4F74A62__INCLUDED_) #define AFX_CSERIAL_H__631473E2_F58F_42EF_BB8E_3CBEC4F74A62__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "Common.h" typedef BYTE COMMERR; #define COMM_OK 0x00 //Everything is okay #define COMMERR_OUTOFMEM 0x01 //Not enough memory to perform the action. #define COMMERR_OPEN 0x10 //The port is already opened. #define COMMERR_INVALID 0x11 //The port is not available. #define COMMERR_FAILPROP 0x12 //The communication properties failed to work. class CSerial { public: INT m_nComPort; INT m_nBaudRate; BYTE m_byParity; BYTE m_byByteSize; BYTE m_byStopBits; private: HANDLE m_hPort; DWORD m_dwAbortOnError; INT m_nInBufferSize; INT m_nOutBufferSize; public: CSerial(); virtual ~CSerial(); //Port controls COMMERR OpenPort(INT nPortNum); void ClosePort(); //Misc BOOL TestPort(INT nPortNum); INT FindAvailablePort(); //Write & Read data. BOOL WriteString(char* Buffer); BOOL WriteByte(BYTE byValue); BOOL ReadPort(char** hcBuffer, int* pnSize); private: COMMERR SetupPort(); COMMERR ClearPort(); }; #endif // !defined(AFX_CSERIAL_H__631473E2_F58F_42EF_BB8E_3CBEC4F74A62__INCLUDED_)